package hjj.service;

import model.Power;
import model.Role;
import model.User;
import util.Page;
import dao.impl.PowerDAOImpl;
import dao.impl.RoleDAOImpl;
import dao.impl.UserDAOImpl;

public class UserManager {
	UserDAOImpl userdaoimpl=new UserDAOImpl();
	
	public Page<User> getAll(int pageNo, int pageSize){
		return userdaoimpl.getAll(pageNo, pageSize);
	}
	
	public Page<User> getUserByName(int pageNo, int pageSize,String name){
		return userdaoimpl.getByName(pageNo, pageSize, name);
	}
	
	public Page<User> getUserByRole(int pageNo, int pageSize,String userrole){
		RoleDAOImpl rdi=new RoleDAOImpl();
		Role role=rdi.getByName(userrole);
		return userdaoimpl.getByRole(pageNo, pageSize, role);
	}
	
	public Page<User> getUserByPower(int pageNo, int pageSize,String userpower){
		PowerDAOImpl pdi=new PowerDAOImpl();
		Power power=pdi.getPowerByName(userpower);
		return userdaoimpl.getByPower(pageNo, pageSize, power);
	}
	
	public Page<User> getUserByStatus(int pageNo, int pageSize,String userstatus){
		if("可用".equals(userstatus)){
			return userdaoimpl.getByStatus(pageNo, pageSize, true);
		}else{
			return userdaoimpl.getByStatus(pageNo, pageSize, false);
		}
	}
	
}
